using System.Drawing;
using _3Dto2D.Models;

namespace _3Dto2D.Interfaces;

public interface ILibraryManager : IDisposable
{
    Task<LibraryData?> LoadLibraryAsync(string filePath, bool isReference = false);
    Task SaveLibraryAsync(string filePath, LibraryData library, bool isReference = false);
    
    Task<FrameData?> GetFrameAsync(LibraryData library, int frameIndex);
    Task AddFrameAsync(LibraryData library, Bitmap image, short offsetX, short offsetY);
    Task ReplaceFrameAsync(LibraryData library, int frameIndex, Bitmap image, short offsetX, short offsetY);
    Task RemoveFrameAsync(LibraryData library, int frameIndex);
    
    Task<LibraryData> CreateLibraryAsync();
    Task<int> GetFrameCountAsync(LibraryData library);
}

public interface IProgressReporter<T>
{
    event EventHandler<ProgressEventArgs<T>>? ProgressChanged;
    Task ProcessWithProgressAsync<TItem>(IEnumerable<TItem> items, Func<TItem, Task<T>> processor);
}

public class ProgressEventArgs<T> : EventArgs
{
    public int Percentage { get; init; }
    public int CurrentItem { get; init; }
    public int TotalItems { get; init; }
    public T? Result { get; init; }
    public string? Message { get; init; }
}
